package com.gxa.modules.app.hospitalization.persional.controller;


import com.gxa.common.utils.Result;
import com.gxa.modules.app.hospitalization.persional.dto.PatientUpdatedto;
import com.gxa.modules.app.hospitalization.persional.service.PatientService;
import com.gxa.modules.model.entity.fee.Patient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName PatientContorller
 * @Description
 * @Author Mr.YUAN
 * @Date 2022/11/12 11:33
 */
@RestController
@Api(tags = "就诊人接口")
@RequestMapping("/patient")
@Slf4j
public class PatientContorller {
    @Autowired
    private PatientService patientService;

    @ApiOperation("根据登录用户id查找绑定的所有就诊人")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "query",name = "pageNum",value = "当前在那一页",dataType = "int"),
//    })
    @GetMapping("/list")
    public Result list(Integer id){
        List<Patient> query = patientService.query(id);
        return new Result().ok(query);
    }

    @ApiOperation("添加就诊人")
    @PostMapping("/add")
    public Result addPatient(@RequestBody PatientUpdatedto patientUpdatedto) {
        patientService.add(patientUpdatedto);
        return new Result().ok();
    }

    @ApiOperation("更改就诊人信息")
    @PostMapping("/update")
    public Result updatePatient(@RequestBody PatientUpdatedto patientUpdatedto) {
        patientService.updatePatinet(patientUpdatedto);
        return new Result().ok();
    }

    @ApiOperation("删除就诊人")
    @PostMapping("/delete")
    public Result deletePatient(Integer id) {
        patientService.deletebyId(id);
        return new Result().ok();
    }


}